/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pictionary;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import javax.swing.JComponent;

/**
 *
 * @author arturo
 */
public class Lienzo extends JComponent {

    
    Point locationOnScreen;
    ArrayList<Point> trazo;
    int ux;
    int uy;

    Lienzo(){


    setPreferredSize(new Dimension(80, 60));
    locationOnScreen = new Point(10, 10);
    setFocusable(true);
    requestFocus();
    trazo = new ArrayList<Point>();

       addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDragged(MouseEvent e) {
                locationOnScreen = e.getPoint();
                trazo.add(locationOnScreen);
                repaint();
                System.out.println("hola");
            }

            

           
       });
  
    }
      
     @Override
    public void paint(Graphics g){

       for(Point i : trazo){
        g.setColor(Color.red);
        g.fillOval(i.x, i.y, 5, 5);

        }
        
      }

    
    }
